


<?php
// ========================================================================================================================================
// Barra com título de bloco da home
// ========================================================================================================================================
function do_title_bloc_news ($titulo, $icon) { ?>
    <div class="bg-amarelo-titulo">
		<div style="float:left;padding:5px 0 0 0;">
			<img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/icon_home/'.$icon.'.png' ?>" width="32px" height="32px" >
		</div>
		<div style="padding:11px 0 8px 37px;">
			<h1><?php echo $titulo; ?></h1>
		</div>
	</div>
	<div class="clr"></div>
<?php
}
// ========================================================================================================================================


// ========================================================================================================================================
// Bloco de notícias em destaque, mostra n notícia em linhas (Horizontal) 
// ========================================================================================================================================
function do_bloco_destaque_noticias ($titulo, $icon, $categoria, $qtde, $corte) { 
	do_title_bloc_news ($titulo, $icon); ?>
	<div class="destaque-home">		
		<?php
		$postCount = 0;
		$the_query = new WP_Query('category_name='.$categoria.'&posts_per_page='.$qtde.'&offset='.$corte); 
		if ( $the_query->have_posts() ) : 
			while ( $the_query->have_posts() ) : $the_query->the_post();
				$postCount = $postCount + 1;
				if ( has_post_thumbnail() ) { ?>
					<div style="margin: 10px 0 0 0;height:auto; width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin: 10px 0 0 0;height:auto; width:140px;background-color:#fff;float:left;">
						<div style="float:left;margin-right:10px;width:140px;">					
							<?php the_post_thumbnail('mini'); ?>
						</div>
					</div>
					<div style="margin: 10px 0 0 0;height:auto; width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin: 10px 0 0 0;height:auto; width:474px;background-color:#fff;float:left;">
						<h2><?php the_title(); ?></h2>
						<p style="color:#020202;font-size:10px;margin:5px 0 5px 0;"><?php the_time(get_option('date_format')); ?></p>
			    		<p><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(150); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:5px 0 0 0;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>				
					<div style="margin: 0; width:5px;background-color:#efefef;float:right;"></div>					
					<?php
					if ($qtde == 1) { ?>
						<div class="clr"></div>
						<div class="vertical_space_10"></div>
						<?php
						break;
					} 
					if ($qtde <=$qtde && $qtde > 1) { 
						if ($qtde == $postCount) { ?>
							<div class="clr"></div>
							<div class="vertical_space_10"></div>
							<?php
							break;
						} else { ?>
							<div class="clr"></div>
							<div style="border:dotted 1px #efefef;width:618px;margin:5px 5px 5px 5px;"></div>
						<?php
						}
					}					
				} else { ?>
					<div style="margin: 10px 0 0 0;height:auto; width:5px;background-color:#efefef;float:left;"></div>					
					<div style="margin: 10px 0 0 0;height:auto; width:613px;background-color:#fff;float:left;">
						<h2><?php the_title(); ?></h2>
						<p style="color:#020202;font-size:10px;margin:5px 0 5px 0;"><?php the_time(get_option('date_format')); ?></p>
			    		<p><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(150); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:5px 0 0 0;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>				
					<div style="margin: 0; width:5px;background-color:#efefef;float:right;"></div>
					<?php
					if ($qtde == 1) { ?>
						<div class="clr"></div>
						<div class="vertical_space_10"></div>
						<?php
						break;
					} 
					if ($qtde <= $qtde && $qtde > 1) { 
						if ($qtde == $postCount) { ?>
							<div class="clr"></div>
							<div class="vertical_space_10"></div>
							<?php
							break;
						} else { ?>
							<div class="clr"></div>
							<div style="border:dotted 1px #efefef;width:618px;margin:5px 5px 5px 5px;"></div>
						<?php
						}
					}						
				}
			endwhile; 
			wp_reset_postdata();			
		endif; 
		?>
		<div class="clr"></div>		
	</div>
	<div class="clr"></div>
<?php
}
// ========================================================================================================================================




// ========================================================================================================================================
// Bloco de notícias em destaque, mostra n notícia em linhas (Horizontal)
// 
// ========================================================================================================================================
function do_bloco_destaque_noticias_manual ($titulo, $icon, $categoria, $qtde, $corte, $slug=array()) { 
	do_title_bloc_news ($titulo, $icon); ?>
	<div class="destaque-home">		
		<?php
		
		$noticias = explode(",", $slug);
		$postCount = 0;
		$qtde = count($noticias);
		foreach ($noticias as $key => $value) {			
			$the_query = new WP_Query('category_name='.$categoria.'&posts_per_page='.$qtde.'&offset='.$corte.'&name='.$value); 
			if ( $the_query->have_posts() ) : 
				while ( $the_query->have_posts() ) : $the_query->the_post();
					$postCount = $postCount + 1;
					if ( has_post_thumbnail() ) { ?>
					<div style="margin: 10px 0 0 0;height:auto; width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin: 10px 0 0 0;height:auto; width:140px;background-color:#fff;float:left;">
						<div style="float:left;margin-right:10px;width:140px;">					
							<?php the_post_thumbnail('mini'); ?>
						</div>
					</div>
					<div style="margin: 10px 0 0 0;height:auto; width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin: 10px 0 0 0;height:auto; width:474px;background-color:#fff;float:left;">
						<h2><?php the_title(); ?></h2>
						<p style="color:#020202;font-size:10px;margin:5px 0 5px 0;"><?php the_time(get_option('date_format')); ?></p>
			    		<p><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(150); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:5px 0 0 0;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>				
					<div style="margin: 0; width:5px;background-color:#efefef;float:right;"></div>					
					<?php
					if ($qtde == 1) { ?>
						<div class="clr"></div>
						<div class="vertical_space_10"></div>
						<?php
						break;
					} 
					if ($qtde <= $qtde && $qtde > 1) { 
						if ($qtde == $postCount) { ?>
							<div class="clr"></div>
							<div class="vertical_space_10"></div>
							<?php
							break;
						} else { ?>
							<div class="clr"></div>
							<div style="border:dotted 1px #efefef;width:618px;margin:5px 5px 5px 5px;"></div>
						<?php
						}
					}					
				} else { ?>
					<div style="margin: 10px 0 0 0;height:auto; width:5px;background-color:#efefef;float:left;"></div>					
					<div style="margin: 10px 0 0 0;height:auto; width:613px;background-color:#fff;float:left;">
						<h2><?php the_title(); ?></h2>
						<p style="color:#020202;font-size:10px;margin:5px 0 5px 0;"><?php the_time(get_option('date_format')); ?></p>
			    		<p><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(150); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:5px 0 0 0;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>				
					<div style="margin: 0; width:5px;background-color:#efefef;float:right;"></div>
					<?php
					if ($qtde == 1) { ?>
						<div class="clr"></div>
						<div class="vertical_space_10"></div>
						<?php
						break;
					} 
					if ($qtde <=$qtde && $qtde > 1) { 
						if ($qtde == $postCount) { ?>
							<div class="clr"></div>
							<div class="vertical_space_10"></div>
							<?php
							break;
						} else { ?>
							<div class="clr"></div>
							<div style="border:dotted 1px #efefef;width:618px;margin:5px 5px 5px 5px;"></div>
						<?php
						}
					}						
				}
			endwhile; ?>
			<div class="clr"></div> 
			<?php
			wp_reset_postdata();			
		endif; 
		?>	
			
		<?php	
		}
		?>	
		</div>
		<div class="clr"></div>	
<?php			
}
// ========================================================================================================================================








// ========================================================================================================================================
// Bloco de notícias em destaque, mostra n notícia
// ========================================================================================================================================
function do_bloco_destaque_noticias_2 ($titulo, $icon, $categoria, $corte) { 
	do_title_bloc_news($titulo, $icon);?>
	<div class="destaque-home">
		<?php
		$postCount = 0;
		//$the_query = new WP_Query('category_name=noticias&posts_per_page=4'); 
		$the_query = new WP_Query('category_name='.$categoria.'&posts_per_page=4&offset='.$corte); 
		if ( $the_query->have_posts() ) : 
			while ( $the_query->have_posts() ) : $the_query->the_post();					
				if ( has_post_thumbnail() ) { ?> 
					<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin:10px 5px 0 0;height:auto;width:147px;border:0px solid #efefef;float:left;">
						<div style="float:left;margin-right:10px;width:147px;"><div class="clr"></div>					
							<div style="margin:2px;"><?php the_post_thumbnail( 'vai' ); ?></div>
						</div>
						<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
						<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(100); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>
				<?php
				} else { ?>
					<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin:10px 5px 0 0;height:auto;width:147px;border:0px solid #efefef;float:left;">
						<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
						<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(100); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>
				<?php
				}
			endwhile; 
			wp_reset_postdata();
		endif; 
		?>
		<div class="clr"></div>
		<div class="vertical_space_10"></div>		
	</div>
	<div class="clr"></div>
<?php
}
// ========================================================================================================================================


// ========================================================================================================================================
// Bloco de notícias em destaque, mostra n notícia
// ========================================================================================================================================
function do_bloco_destaque_noticias_3 ($titulo, $icon, $categoria, $qtde, $corte) { 
	do_title_bloc_news($titulo, $icon);?>
	<div class="destaque-home">
		<?php
		$postCount = 0;
		//$the_query = new WP_Query('category_name=noticias&posts_per_page=4'); 
		$the_query = new WP_Query('category_name='.$categoria.'&posts_per_page='.$qtde.'&offset='.$corte); 
		if ( $the_query->have_posts() ) : 
			while ( $the_query->have_posts() ) : $the_query->the_post();
				if ($qtde == 4) {
					if ( has_post_thumbnail() ) { ?> 
					<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin:10px 5px 0 0;height:auto;width:147px;border:0px solid #efefef;float:left;">
						<div style="float:left;margin-right:10px;width:147px;">
							<div class="clr"></div>					
							<div style="margin:2px;"><?php the_post_thumbnail( 'mini-3' ); ?></div>
						</div>
						<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
						<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(100); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>
					<?php
					} else { ?>
						<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
						<div style="margin:10px 5px 0 0;height:auto;width:147px;border:0px solid #efefef;float:left;">
							<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
							<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
				    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(100); ?></a></p>
				    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
						</div>
					<?php
					}
				}	
				if ($qtde == 3) {
					if ( has_post_thumbnail() ) { ?> 
					<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin:10px 5px 0 0;height:auto;width:199px;border:0px solid #efefef;float:left;">
						<div style="float:left;margin-right:10px;width:147px;">
							<div class="clr"></div>					
							<div style="margin:2px;"><?php the_post_thumbnail( 'mini-4' ); ?></div>
						</div>
						<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
						<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(100); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>
					<?php
					} else { ?>
						<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
						<div style="margin:10px 5px 0 0;height:auto;width:199px;border:0px solid #efefef;float:left;">
							<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
							<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
				    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(100); ?></a></p>
				    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
						</div>
					<?php
					}
				}
				if ($qtde == 2) {
					if ( has_post_thumbnail() ) { ?> 
					<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin:10px 5px 0 0;height:auto;width:303px;border:0px solid #efefef;float:left;">
						<div style="float:left;margin-right:10px;width:303px;">
							<div class="clr"></div>					
							<div style="margin:2px;"><?php the_post_thumbnail( 'mini-5' ); ?></div>
						</div>
						<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
						<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(100); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>
					<?php
					} else { ?>
						<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
						<div style="margin:10px 5px 0 0;height:auto;width:303px;border:0px solid #efefef;float:left;">
							<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
							<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
				    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(100); ?></a></p>
				    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
						</div>
					<?php
					}
				}
				if ($qtde == 1) {
					if ( has_post_thumbnail() ) { ?> 
					<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
					<div style="margin:10px 5px 0 0;height:auto;width:618px;border:0px solid #efefef;float:left;">
						<div style="float:left;margin-right:10px;width:618px;">
							<div class="clr"></div>					
							<div style="margin:2px;"><?php the_post_thumbnail( 'mini-6' ); ?></div>
						</div>
						<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
						<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(300); ?></a></p>
			    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
					</div>
					<?php
					} else { ?>
						<div style="margin:10px 0 0 0;height:auto;width:5px;background-color:#efefef;float:left;"></div>
						<div style="margin:10px 5px 0 0;height:auto;width:618px;border:0px solid #efefef;float:left;">
							<div style="margin:10px 2px 2px 2px;"><h2><?php the_title(); ?></h2></div>
							<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><?php the_time(get_option('date_format')); ?></p>
				    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;"><a style="color:#020202;" href="<?php echo get_post_meta($post->ID, 'url', true); ?>" target="_blank"><?php the_excerpt_max_charlength(300); ?></a></p>
				    		<p style="color:#020202;font-size:10px;margin:10px 2px 5px 2px;">Fonte: <?php echo get_post_meta(get_the_ID(), 'avpt_noticias_fonte', true); ?></p>
						</div>
					<?php
					}
				}
			endwhile; 
			wp_reset_postdata();
		endif; 
		?>
		<div class="clr"></div>
		<div class="vertical_space_10"></div>		
	</div>
	<div class="clr"></div>
<?php
} 
// ========================================================================================================================================

?>



